package first.demo;

public class TestAuto {
    public static void main(String[] args) {
        int number=5;
        Bus b=new Bus();
        b.getOn(number);
        b.getOff(number);
        b.start();
        b.speedup();
        b.stop();

    }
}

class Auto{
    private double speed=0;
    public void start(){
        speed=10;
        System.out.print("汽车启动!");
        System.out.println("汽车速度:"+speed);
    }
    public void speedup(){
        speed+=10;
        System.out.print("汽车加速!");
        System.out.println("汽车速度:"+speed);
    }
    public void stop(){
        speed=0;
        System.out.print("汽车停止!");
        System.out.println("汽车速度:"+speed);
    }

}
class Bus extends Auto{
    private int passenger=0;
    public void getOn(int number){
        passenger+=number;
        System.out.print("乘客已上车 ");
        System.out.println("车上人数:"+passenger);
    }
    public void getOff(int number){
        passenger-=number;
        System.out.print("乘客已下车 ");
        System.out.println("车上人数:"+passenger);
    }

}